package com.zzptc.myk.myapplication.ui.home;

import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProviders;

import com.zzptc.myk.myapplication.Adapter.ShoesAdapter;
import com.zzptc.myk.myapplication.Bean.Shoes;
import com.zzptc.myk.myapplication.R;

import org.litepal.LitePal;

import java.util.ArrayList;
import java.util.List;

public class HomeFragment extends Fragment {
    private ListView chooselv;
    ShoesAdapter adapter;
    List<Shoes> bookList=new ArrayList<>();

    public View onCreateView(@NonNull LayoutInflater inflater,
                             ViewGroup container, Bundle savedInstanceState) {

        View view = inflater.inflate(R.layout.fragment_home, container, false);
        getShoes();
        initView(view);
        return view;
    }

    private void getShoes() {
        bookList.add(new Shoes(0,"Nike Air Force 1 React LX 3M","949",R.mipmap.q));
        bookList.add( new Shoes(1,"Nike Air Barrage Low","899",R.mipmap.b));
        bookList.add(new Shoes(2,"Nike AF1 Shadow SE","899",R.mipmap.a));
    }


    private void initView(View view) {
        chooselv=view.findViewById(R.id.chooselv);
        adapter=new ShoesAdapter(getContext(),R.layout.shoes_item,bookList);
        chooselv.setAdapter(adapter);
    }
}